import 'package:flutter/material.dart';

import '../model/demo_model.dart';

class DemoScreenPage extends StatelessWidget {
  DemoScreenPage({Key? key}) : super(key: key);

  final DemoModel _demoModel = DemoModel();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("demo"),
      ),
      body: Container(
        padding: const EdgeInsets.all(10),
        child: Column(
          children: [
            StreamBuilder(
              stream: _demoModel.stream,
              builder: (BuildContext context, AsyncSnapshot<int> snapshot) {
                return Text("${snapshot.data}");
              },
            ),
            StreamBuilder(
              stream: _demoModel.streamDemo,
              builder: (BuildContext context, AsyncSnapshot<int> snapshot) {
                return Text("${snapshot.data}");
              },
            ),
            InkWell(
              onTap: () => {
                _demoModel.increment()
              },
              child: Container(
                height: 40,
                width: 100,
                alignment: Alignment.center,
                decoration: const BoxDecoration(
                    color: Colors.blueAccent,
                    borderRadius: BorderRadius.all(Radius.circular(10))),
                child: const Text(
                  "添加",
                  style: TextStyle(color: Colors.white),
                ),
              ),
            )
          ],
        ),
      ),
    );
  }
}
